package com.gome.ocean.service.gddl.impl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.gome.ocean.dao.gddl.AppDatasourceDAO;
import com.gome.ocean.dao.model.gddl.AppDatasourceBO;
import com.gome.ocean.service.gddl.AppDatasourceService;


@Service("appDatasourceService")
@Transactional("transactionManager")
public class AppDatasourceServiceImpl implements AppDatasourceService {

    @Autowired
    private AppDatasourceDAO appDatasourceDAO;

    @Override
    public boolean saveAppDatasourceBO(AppDatasourceBO appDatasourceBO) {
        return appDatasourceDAO.saveAppDatasourceBO(appDatasourceBO) > 0;
    }

    @Override
    public boolean deleteAppDatasourceBOById(Long id) {
        return appDatasourceDAO.deleteAppDatasourceBOById(id) > 0;
    }

    @Override
    public boolean updateAppDatasourceBOById(AppDatasourceBO appDatasourceBO) {
        return appDatasourceDAO.updateAppDatasourceBOById(appDatasourceBO) > 0;
    }

    @Override
    public AppDatasourceBO findAppDatasourceBOById(Long id) {
        return appDatasourceDAO.findAppDatasourceBOById(id);
    }

    @Override
    public AppDatasourceBO findAppDatasourceBOByDbNameAndJdbcUrl(String dbName, String jdbcUrl) {
        return appDatasourceDAO.findAppDatasourceBOByDbNameAndJdbcUrl(dbName, jdbcUrl);
    }

    @Override
    public List<AppDatasourceBO> findAllDataSource() {
        return appDatasourceDAO.findAllDataSource();
    }

	@Override
	public List<AppDatasourceBO> findAppDataSourceByDbName(String dbName) {
		return appDatasourceDAO.findAppDataSourceByDbName(dbName);
	}

	@Override
	public Page<AppDatasourceBO> findAllDataSource(int pageNum, int pageSize) {
		return (Page<AppDatasourceBO>)appDatasourceDAO.findAllDataSource(new RowBounds(pageNum, pageSize));
	}

}
